package com.example.controller;

import com.example.common.result.Result;
import com.example.entity.dto.LocationLabelDto;
import com.example.entity.vo.LocationLabelVo;
import com.example.entity.vo.WarehouseStockVo;
import com.example.entity.yifei.Cmsni;
import com.example.service.CmsniService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/Cmsni")
@Api(tags = "仓库库位档前端控制器")
@Slf4j
public class CmsniController {

    @Resource
    private CmsniService cmsniService;

    @ApiOperation("库位查询")
    @GetMapping("/queryIPage/{current}/{size}/{ckbh}")
    public Result<Map<String, Cmsni>> queryIPage(@PathVariable Integer current, @PathVariable Integer size,@PathVariable String ckbh,String code){
        return this.cmsniService.queryList(current,size,ckbh,code);
    }


    @ApiOperation("库位编号")
    @PostMapping("/getWarehouse")
    public Result getLocationLabel(){
        List<LocationLabelVo> materialLabelVoList = cmsniService.getLocationLabel();
        return Result.ok(materialLabelVoList);
    }

    @ApiOperation("库存余量")
    @PostMapping("/getWarehouseStock/{pageNum}/{pageSize}")
    public Result<PageInfo<WarehouseStockVo>> getWarehouseStock(@RequestBody LocationLabelDto locationLabelDto,
                                                                @PathVariable("pageNum") Integer pageNum,
                                                                @PathVariable("pageSize") Integer pageSize){
        return cmsniService.getWarehouseStock(locationLabelDto,pageNum,pageSize);
    }
}
